#include <vector>
#include "test.hpp"
#include "object.hpp"
#include "behaviors_recorder.hpp"

using std::vector;

namespace vimock {
class my_exception : public std::exception {
};
TEST_CASE(record_value_to_return_test)
{
	object obj(1);
	object func(2);
	object_vector arguments(new vector<object>());
	object arg(3);
	arguments->push_back(arg);
	invocation inv(new _invocation(obj, func, arguments));

	behaviors_recorder recorder;
	recorder.record_invocation(inv);
	object value_to_return(4);
	recorder.record_value_to_return(value_to_return);

	behavior_vector behaviors(recorder.get_behaviors());
	assert_are_equal(static_cast<unsigned int>(1), behaviors->size());
	behavior behavior((*behaviors)[0]);
	assert_are_equal(value_to_return.to<int>(), behavior->replay(inv).to<int>());
}
TEST_CASE(record_exception_to_throw_test)
{
	object obj(1);
	object func(2);
	object_vector arguments(new vector<object>());
	object arg(3);
	arguments->push_back(arg);
	invocation inv(new _invocation(obj, func, arguments));

	behaviors_recorder recorder;
	recorder.record_invocation(inv);
	recorder.record_exception_to_throw(my_exception());

	behavior_vector behaviors(recorder.get_behaviors());
	assert_are_equal(static_cast<unsigned int>(1), behaviors->size());
	behavior behavior((*behaviors)[0]);
	assert_thrown(my_exception, behavior->replay(inv));
}
}
